import { Body, Controller, Get, Post, Req, Res } from '@nestjs/common';
import { FastifyRequest, FastifyReply } from 'fastify';
import { ApiService } from './api.service';

@Controller('/api')
export class ApiController {

    constructor(private readonly apiService: ApiService) { }

    /**
     * @description 执行Post代理请求
     * 
     * @memberof PlayerController
     */
    @Post('/*')
    async executePostProxy(@Req() req: FastifyRequest, @Res() res: FastifyReply, @Body() body): Promise<any> {
        await this.apiService.executePostAction(req, res, body);
    }

    /**
     * @description 执行Get代理请求
     * 
     * @memberof PlayerController
     */
    @Get('/*')
    async executeGetProxy(@Req() req: FastifyRequest, @Res() res: FastifyReply, @Body() body): Promise<any> {
        await this.apiService.executeGetAction(req, res);
    }

}
